home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / fpu881 / src6.zoo / crcp.c < prev    next >
C/C++ Source or Header  |  1991-09-24  |  2KB  |  79 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    crcp   complex double precision reciprocal
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    crcp
  29.  *    complex functions
  30.  *    math libraries
  31.  *
  32.  *  DESCRIPTION
  33.  *
  34.  *    Computes double precision complex reciprocal of
  35.  *    a double precision complex argument.
  36.  *
  37.  *  USAGE
  38.  *
  39.  *    COMPLEX crcp (z)
  40.  *    COMPLEX z;
  41.  *
  42.  *  PROGRAMMER
  43.  *
  44.  *    Fred Fish
  45.  *    Tempe, Az 85281
  46.  *    (602) 966-8871
  47.  *
  48.  *  INTERNALS
  49.  *
  50.  *    Computes complex reciprocal of z = x + j y from:
  51.  *
  52.  *        1.    Compute denom = x*x + y*y
  53.  *
  54.  *        2.    If denom = 0.0 then flag error
  55.  *            and return MAX_POS_DBLF + j 0.0
  56.  *
  57.  *        3.    Else crcp(z) = (x/denom) + j (-y/denom)
  58.  *
  59.  */
  60.  
  61. #include <stdio.h>
  62. #include <pmluser.h>
  63. #include "pml.h"
  64.  
  65.  
  66. COMPLEX crcp (z)
  67. COMPLEX z;
  68. {
  69.     double denom;
  70.  
  71. /* MJR: IEEE knows signed Infinity, so there is no need to check
  72.         if denom == 0
  73. */
  74.     denom = (z.real * z.real) + (z.imag * z.imag);
  75.     z.real /= denom;
  76.     z.imag /= -denom;
  77.     return (z);
  78. }
  79.